#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;


int buketList(){
    ifstream ifs("BucketList.in");
    ofstream ofs("BucketList.out");

    int cows = 0;
    ifs>>cows;
    
    vector<int> events(1000, 0);
    int start = 0, stop = 0, buket = 0;

    for(int i = 0; i < cows; ++i){
        ifs>>start>>stop>>buket;
        events[start] = buket;
        events[stop] = -buket;
    }
  
    int curbuket = 0;
    int maxbuket = 0;

    for(auto i = events.begin(); i != events.end(); ++i){
        curbuket += *i;
        maxbuket = max(maxbuket, curbuket);
    }

    ofs<<maxbuket;

    return maxbuket;
}

int main(int argc, char const *argv[])
{
    /* code */
    cout<<buketList()<<endl;

    return 0;
}
